#include "CCharactersSelection.h"

CCharactersSelection::CCharactersSelection()
{
    this->character1 = new MCharacter;
    this->character2 = new MCharacter;
    this->character3 = new MCharacter;
    this->character4 = new MCharacter;
    this->character5 = new MCharacter;

    this->characters.append(this->character1);
    this->characters.append(this->character2);
    this->characters.append(this->character3);
    this->characters.append(this->character4);
    this->characters.append(this->character5);
}

CCharactersSelection::~CCharactersSelection()
{
    delete this->character1;
    delete this->character2;
    delete this->character3;
    delete this->character4;
    delete this->character5;
}

QList<MCharacter *> CCharactersSelection::get_characters()
{
    characters.empty();

    for (int i = 0; i < 5; i++)
    {
        characters.at(i)->set_id(CTcpNetwork::get_instance()->receive().toInt());
        characters.at(i)->set_username(CTcpNetwork::get_instance()->receive());
        characters.at(i)->set_map_ip(CTcpNetwork::get_instance()->receive());
        characters.at(i)->set_map_name(CTcpNetwork::get_instance()->receive());
        characters.at(i)->set_map_port(CTcpNetwork::get_instance()->receive());
        characters.at(i)->set_level(CTcpNetwork::get_instance()->receive().toInt());
        characters.at(i)->set_exp(CTcpNetwork::get_instance()->receive().toInt());
        characters.at(i)->set_bonus(CTcpNetwork::get_instance()->receive());
    }

    return this->characters;
}
